package com.cnap.utils;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
 * <类文件描述>
 *
 * @author xc
 **/
class TokenUtilsTest {

    @Test
    void setTOKEN() {
        String token = "eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NjUyMjI3ODksInN1YiI6ImFkbWluIiwiaWF0IjoxNjY1MjA4Mzg5MzE1fQ._FxOBy7ChUuuSOYnAJOuK1S_IMdkH45VMC1Sd59bSUY";

        Assertions.assertDoesNotThrow(()->{
            TokenUtils.setTOKEN(token);
        });
    }

    @Test
    void getTOKEN() {
        String token = "eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NjUyMjI3ODksInN1YiI6ImFkbWluIiwiaWF0IjoxNjY1MjA4Mzg5MzE1fQ._FxOBy7ChUuuSOYnAJOuK1S_IMdkH45VMC1Sd59bSUY";
        TokenUtils.setTOKEN(token);

        String s = TokenUtils.getTOKEN();
        Assertions.assertEquals(s, token);
    }

    @Test
    void getUserName() {
        String token = "eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NjUyMjI3ODksInN1YiI6ImFkbWluIiwiaWF0IjoxNjY1MjA4Mzg5MzE1fQ._FxOBy7ChUuuSOYnAJOuK1S_IMdkH45VMC1Sd59bSUY";
        TokenUtils.setTOKEN(token);

        String user = TokenUtils.getUserName();
        Assertions.assertEquals("admin", user);
    }
}